package com.cy.pj.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.pojo.SysMenu;
import com.cy.pj.sys.service.SysMenuService;

@RequestMapping("/menu/")
@RestController
public class SysMenuController {

	@Autowired
	private SysMenuService sysMenuService;
	
	//查询所有菜单信息
	@RequestMapping("doFindObjects")
	public JsonResult dofindObjects() {
		return new JsonResult(sysMenuService.findObjects());
	}
	
	//删除菜单
	@RequestMapping("doDeleteObject")
	public JsonResult doDeleteObject(Integer id) {
		sysMenuService.deleteObject(id);
		return new JsonResult("删除成功");
	}
	
	//点击上级菜单后查询所有的菜单信息再返回给页面
	@RequestMapping("doFindZtreeMenuNodes")
	public JsonResult doFindZtreeMenuNodes() {
		return new JsonResult(sysMenuService.findZtreeMenuNodes());
	}
	
	
	//新增菜单
	@RequestMapping("doSaveObject")
	public JsonResult doSaveObjects(SysMenu entity) {
		sysMenuService.saveObject(entity);
		return new JsonResult("新增成功");
	}
	
	
	//修改菜单
	@RequestMapping("doUpdateObject")
	public JsonResult doUpdateObject(SysMenu entity) {
		sysMenuService.updataObjecs(entity);
		return new JsonResult("修改成功");
	}
}
